**Chilad labour Effects of Cocoa Price
clear
clear matrix
clear mata
cap log close
************************************************************************************
**change directory here
* DIRECTORY ROADMAP
sysdir set PLUS C:\ado\plus\c
************************************************************************************

global dir1 C:\Users\hab55\Dropbox\Second_paper_Ghana\2023_EDCC_Price\Data
global dir2 C:\Users\hab55\Dropbox\Second_paper_Ghana\2023_EDCC_Price\Do
global dir3 C:\Users\hab55\Dropbox\Second_paper_Ghana\2023_EDCC_Price\Output

///////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
use "$dir1\labourmarket_glss_final.dta", clear
global controlds "worky agri_selfy nonagri_selfy"

///Table B.3

eststo A: estpost summarize $controlds if agey>=6 & agey<=17
eststo B: estpost summarize $controlds if agey>=6 & agey<=11
eststo C: estpost summarize $controlds if  agey>11 & agey<=14
eststo D: estpost summarize $controlds if agey>14 & agey<=17
//eststo E: estpost summarize $controlds if agey>17 & agey<=65

esttab A B C D  using "$dir3\Summary.tex", replace  main(mean %6.2f sd ) aux(count) mtitle("Total sample" "Primary" "Juniour High" "Senior High")
esttab A B C D  using "$dir3\Summary.tex", replace label cell(" mean(fmt(3)) sd(fmt(3)) count(fmt(0))") mtitle("Total sample" "Primary" "Juniour High" "Senior High")
///////////////////////////////////////////////////////////////////////////
//Table B.4: Panel A
eststo E: estpost summarize $controlds if agey>17 & agey<=65

esttab E using "$dir3\Summary1.tex", replace  main(mean %6.2f sd ) aux(count) mtitle("Adult")
esttab E using "$dir3\Summary1.tex", replace label cell(" mean(fmt(3)) sd(fmt(3)) count(fmt(0))") mtitle("Adult")
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
use "$dir4\labourmarket_glss_final", clear

//Table C.4
//child labour 
///Panel A: any work

areg worky shockc  i.agey gender genderhd i.YOB i.year i.ROB#c.year [aw=weight] if agey>=6 & agey<=17, ab ( ROB  ) cluster (ROB)
boottest shockc=0,  nograph  seed(321448699) 

outreg2 using "$dir3\work.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg worky shockc i.agey gender genderhd i.YOB i.year i.ROB#c.year [aw=weight] if agey>=6 & agey<=11, ab ( ROB) cluster (ROB)
boottest shockc=0,  nograph  seed(321448699) 

outreg2 using "$dir3\work.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg worky shockc i.agey gender genderhd i.YOB i.year i.ROB#c.year [aw=weight] if agey>11 & agey<=14, ab ( ROB ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg worky shockc i.agey gender genderhd i.YOB i.year i.ROB#c.year [aw=weight] if agey>14 & agey<=17, ab ( ROB ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)
////////////////////////////////////////////////////////////////////////////////

///Panel B: agriculture work

areg agri_selfy shockc  i.agey gender genderhd i.year i.ROB#c.year i.YOB [aw=weight] if agey>5 & agey<=17, ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg agri_selfy shockc  i.agey gender genderhd  i.year i.ROB#c.year i.YOB [aw=weight] if agey>5 & agey<=11, ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699)

outreg2 using "$dir3\work1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg agri_selfy shockc  i.agey gender genderhd i.year i.ROB#c.year i.YOB [aw=weight] if agey>11 & agey<=14, ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg agri_selfy shockc  i.agey gender genderhd i.year i.ROB#c.year i.YOB [aw=weight] if agey>14 & agey<=17, ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)


/////Panel C: non agriculture work
areg nonagri_selfy shockc  i.agey gender genderhd i.year i.YOB i.ROB#c.year [aw=weight] if agey>5 & agey<=17,ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg nonagri_selfy shockc  i.agey gender genderhd i.year i.YOB i.ROB#c.year [aw=weight] if agey>5 & agey<=11, ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg nonagri_selfy shockc  i.agey gender genderhd i.year i.YOB i.ROB#c.year [aw=weight] if agey>11 & agey<=14, ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg nonagri_selfy shockc  i.agey gender genderhd i.year i.YOB i.ROB#c.year [aw=weight] if agey>14 & agey<=17, ab ( ROB) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

/////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
////Table C.5:
///IV second stage 
//Panel A: Any Work 

ivreg2  worky  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=6 & agey<=17,   cluster (ROB)  
boottest shockc=0 ,     nograph   
outreg2 using "$dir3\labour_international_IV_trend.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)


ivreg2  worky  (shockc=shocki ) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=6 & agey<=11,   cluster (ROB)  
boottest shockc=0 ,    nograph  
outreg2 using "$dir3\labour_international_IV_trend.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  worky  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=12 & agey<=14,   cluster (ROB)  
boottest shockc=0 ,    nograph  
outreg2 using "$dir3\labour_international_IV_trend.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  worky  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=15 & agey<=17,   cluster (ROB)  
boottest shockc=0 ,     nograph  
outreg2 using "$dir3\labour_international_IV_trend.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)


/////Panel B: Agri Work 
ivreg2  agri_selfy  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=6 & agey<=17,   cluster (ROB)  
boottest shockc=0 ,     nograph   
outreg2 using "$dir3\labour_international_IV_trend1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  agri_selfy  (shockc=shocki ) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=6 & agey<=11,   cluster (ROB)  
boottest shockc=0 ,    nograph  
outreg2 using "$dir3\labour_international_IV_trend1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  agri_selfy  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=12 & agey<=14,   cluster (ROB)  
boottest shockc=0 ,    nograph  
outreg2 using "$dir3\labour_international_IV_trend1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  agri_selfy  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=15 & agey<=17,   cluster (ROB)  
boottest shockc=0 ,     nograph  
outreg2 using "$dir3\labour_international_IV_trend1.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)


//Panel C: Non-agri Work 

ivreg2  nonagri_selfy  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=6 & agey<=17,   cluster (ROB)  
boottest shockc=0 ,     nograph   
outreg2 using "$dir3\labour_international_IV_trend2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  nonagri_selfy  (shockc=shocki ) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=6 & agey<=11,   cluster (ROB)  
boottest shockc=0 ,    nograph  
outreg2 using "$dir3\labour_international_IV_trend2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  nonagri_selfy  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=12 & agey<=14,   cluster (ROB)  
boottest shockc=0 ,    nograph  
outreg2 using "$dir3\labour_international_IV_trend2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

ivreg2  nonagri_selfy  (shockc=shocki) i.agey gender genderhd  i.ROB#c.year i.YOB i.ROB i.year  [aw=weight] if agey>=15 & agey<=17,   cluster (ROB)  
boottest shockc=0 ,     nograph  
outreg2 using "$dir3\labour_international_IV_trend2.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

////////////////////////////////////////////////////////////////////////////////
//////Table C.6:
///last 12 months attendance

areg attendance shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>=6 & agey<=17, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\attendance_las12.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg attendance shockc i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>=6 & agey<=11, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\attendance_las12.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg attendance shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>11 & agey<=14, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\attendance_las12.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

areg attendance shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>14 & agey<=17, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\attendance_las12.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)
////////////////////////////////////////////////////////////////////////////////////////
///Table C.7:
///adult labour supply

///any work
areg worky shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>17 & agey<=65, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work4.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

///agri

areg agri_selfy shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight]if agey>17 & agey<=65, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work4.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

////non-agri
areg nonagri_selfy shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>17 & agey<=65, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work4.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
///Table D.5:
///mothers labour supply

///any work
areg worky shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>17 & agey<=45 & gender==0, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work_mothers.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

///agri

areg agri_selfy shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>17 & agey<=45 & gender==0, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work_mothers.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

////non-agri
areg nonagri_selfy shockc  i.agey gender genderhd i.ROB#c.year i.year i.YOB [aw=weight] if agey>17 & agey<=45 & gender==0, ab ( ROB   ) cluster (ROB)
boottest shockc=0 ,  nograph  seed(321448699) 

outreg2 using "$dir3\work_mothers.tex", keep(shockc ) stats(coef se) bdec(3) sdec(3) nocons  label addtext(Region FE, Yes, Survey year FE, Yes, Region time trends, Yes)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////